<html>
<head><meta charset="utf-8"><title>Forging requests · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html">Forging requests</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="230241859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230241859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ivan770 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230241859">(Mar 14 2021 at 14:30)</a>:</h4>
<p>While trying to work on <a href="https://github.com/rust-analyzer/rust-analyzer/issues/6823">https://github.com/rust-analyzer/rust-analyzer/issues/6823</a> I ran into a trouble of forging requests without modifying TS extension part of RA. Is there any way to invoke arbitrary methods from VS Code by just passing custom JSON?</p>



<a name="230241937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230241937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230241937">(Mar 14 2021 at 14:31)</a>:</h4>
<p>I don't think so. But I think that feature requires custom TS anyway?</p>



<a name="230241999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230241999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ivan770 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230241999">(Mar 14 2021 at 14:32)</a>:</h4>
<p>Yep. But I decided to start from Rust part, and only then work on TS</p>



<a name="230242199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230242199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230242199">(Mar 14 2021 at 14:35)</a>:</h4>
<p>For the rust part, I'd go with just writing unit-tests in the IDE module (how, eg, join_lines work). When integrating with LSP, I don't think there's an easier way then just writing both the rust and the TS parts together. On the bright side, the LSP part should be mostly trivial, so it often just writes itself from the definitions of request/response types.</p>



<a name="230475799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230475799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ivan770 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230475799">(Mar 16 2021 at 08:27)</a>:</h4>
<p>I guess Rust part is done, and tests are passing, though I'm not sure about chosen API. Is it ok to just ask for a cursor position and direction? <a href="/user_uploads/4715/sE5VRXvEza4j04mU7busCPOo/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/sE5VRXvEza4j04mU7busCPOo/image.png" title="image.png"><img src="/user_uploads/4715/sE5VRXvEza4j04mU7busCPOo/image.png"></a></div>



<a name="230476026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230476026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230476026">(Mar 16 2021 at 08:30)</a>:</h4>
<p>Seem right overall</p>



<a name="230476065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230476065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ivan770 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230476065">(Mar 16 2021 at 08:30)</a>:</h4>
<p>On VS Code side this can be implemented as two different commands, so that user bindings are possible</p>



<a name="230476078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230476078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230476078">(Mar 16 2021 at 08:30)</a>:</h4>
<p>You probably want <code>lsp_types::TextDocumentEdit</code> instead of just a vector of edits</p>



<a name="230476175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230476175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230476175">(Mar 16 2021 at 08:31)</a>:</h4>
<p>And I think it's best to use <code>Range</code> rather than <code>Position</code> for input, such that we can extend this to multiple items in the futuer</p>



<a name="230476303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230476303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ivan770 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230476303">(Mar 16 2021 at 08:32)</a>:</h4>
<p>Got it. Thanks!</p>



<a name="230531050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230531050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ivan770 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230531050">(Mar 16 2021 at 15:18)</a>:</h4>
<p>Are there any issues with CI? Cross is failing to compile, other ones (and my local build) are successful. <a href="https://github.com/rust-analyzer/rust-analyzer/pull/8054/checks">https://github.com/rust-analyzer/rust-analyzer/pull/8054/checks</a></p>



<a name="230531744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230531744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230531744">(Mar 16 2021 at 15:22)</a>:</h4>
<p>needs a rebase(/</p>



<a name="230531750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230531750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230531750">(Mar 16 2021 at 15:22)</a>:</h4>
<p>?</p>



<a name="230532035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230532035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230532035">(Mar 16 2021 at 15:23)</a>:</h4>
<p>I can't reproduce locally with <code>cargo check --all-targets --target powerpc-unknown-linux-gnu</code>, but rebasing might be a good idea</p>



<a name="230533471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/230533471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ivan770 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#230533471">(Mar 16 2021 at 15:31)</a>:</h4>
<p>Yep, looks like that helped. Thanks.</p>



<a name="231035763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Forging%20requests/near/231035763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ivan770 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Forging.20requests.html#231035763">(Mar 19 2021 at 14:56)</a>:</h4>
<p>I guess item movers are ready for review - <a href="https://github.com/rust-analyzer/rust-analyzer/pull/8054">https://github.com/rust-analyzer/rust-analyzer/pull/8054</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>